﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;

namespace feixiangCMS
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码、svc 和配置文件中的类名“AjaxService”。
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class AjaxService : ICMS.IAjaxService
    {
        CMSDB.DBManager db = new CMSDB.DBManager();
        public string Login(string username, string password)
        {
            ICMS.IAjaxService service = new CMSService.UserService(db);
            string result = service.Login(username, password);//这是一个单字符串的返回，前台获取的方法 var a = eval(msg);if (String(a.d).length > 0）{alert(a.d);}

            //string result = "{\"schema\":[{\"name\":\"AREA\",\"type\":\"string\"},{\"name\":\"ADCD\",\"type\":\"string\"},{\"name\":\"VAL\",\"type\":\"decimal\"},{\"name\":\"STNM\",\"type\":\"string\"},{\"name\":\"row\",\"type\":\"long\"}],\"data\":[{\"AREA\":\"洪洋乡\",\"ADCD\":\"350123201000000\",\"VAL\":\"2.0\",\"STNM\":\"厝坪-气象\",\"row\":\"1\"},{\"AREA\":\"霍口畲族乡\",\"ADCD\":\"350123203000000\",\"VAL\":\"1.0\",\"STNM\":\"斌溪水库-防汛\",\"row\":\"1\"},{\"AREA\":\"白塔乡\",\"ADCD\":\"350123200000000\",\"VAL\":\"1.0\",\"STNM\":\"苏区水库-水文\",\"row\":\"1\"},{\"AREA\":\"凤山镇\",\"ADCD\":\"350123100000000\",\"VAL\":\"1.0\",\"STNM\":\"罗源-防汛\",\"row\":\"1\"},{\"AREA\":\"松山镇\",\"ADCD\":\"350123101000000\",\"VAL\":\"1.0\",\"STNM\":\"松山围垦-防汛\",\"row\":\"1\"},{\"AREA\":\"西兰乡\",\"ADCD\":\"350123202000000\",\"VAL\":\"0.0\",\"STNM\":\"洋坪-防汛\",\"row\":\"1\"},{\"AREA\":\"鉴江镇\",\"ADCD\":\"350123105000000\",\"VAL\":\"0.0\",\"STNM\":\"碧里-气象\",\"row\":\"1\"}]}";  //这是一个数组的返回，前台获取的方法  var a = eval(msg);if (String(a.d).length > 0){var _array = eval('(' + a.d + ')');alert(_array.schema.length);}
            return result;
        }


        public string Vote(int votingId, int optionId, int userId)
        {
            throw new NotImplementedException();
        }

        public string Reply(int docId, int userId, string content)
        {
            throw new NotImplementedException();
        }

        public string Recommend(int docId, int userId)
        {
            throw new NotImplementedException();
        }
    }
}